<?php
// 本文档自动生成，仅供测试运行
class IndexAction extends Action {
	/**
	 +----------------------------------------------------------
	 * 默认操作
	 +----------------------------------------------------------
	 */
	public function index() {
		//$this->display('/Login/loginPage.html');
		//$this->display();
		//$this -> display();
		$this->redirect("Login/loginPage");
	}

	/**
	 +----------------------------------------------------------
	 * 探针模式
	 +----------------------------------------------------------
	 */
	public function checkEnv() {
		load('pointer', THINK_PATH . '/Tpl/Autoindex');
		//载入探针函数
		$env_table = check_env();
		//根据当前函数获取当前环境
		echo $env_table;
	}

	public function studentMain() {

		if (isset($_SESSION['id'])) {
			$id = $_SESSION['id'];
			$name = $_SESSION['name'];
			$stuhomework_dao = M('stuhomework');
			$student_dao = M('student');
			$homeworkinfo_dao = M('homeworkinfo');
			
			$stu_condition['id'] = $_SESSION['id'];
			$student = $student_dao->where($stu_condtion)->find();
			$homework_result = $homeworkinfo_dao->select();
			foreach ($homework_result as $key => $value) {
				$condition['stu_id'] = $id;
				$condition['hw_id'] = $value['id'];
				$stuhomework_result = $stuhomework_dao->where($condition)->find();
				$homework_result[$key]['link'] = $stuhomework_result['link'];
				$homework_result[$key]['file_location'] = $stuhomework_result['file_location'];
				$homework_result[$key]['point'] = $stuhomework_result['point'];
				$homework_result[$key]['rating'] = $stuhomework_result['rating'];
			}
			$this -> assign("homework", $homework_result);
			$this -> assign('student', $student);
			
			
			$this -> display();
			
			
		} else {

		}
	}

	public function adminMain() {
		if (isset($_SESSION['admin_id'])) {
			$this -> id = $_SESSION['admin_id'];
			$this -> name = $_SESSION['admin_name'];
			$homeworkinfo = M('homeworkinfo');
			
			$result = $homeworkinfo -> select();
			$course_dao = M('course');
			$course_condition['id'] = 1;
			$course_result = $course_dao->where($course_condition)->find();
			$this->assign('lock',$course_result['group_lock']);
			$this -> assign('homework', $result);
			$this -> display();
		} else {
			$this->error("请先登录");

		}
	}

}
?>